package libra.constans;

import javax.annotation.PostConstruct;
import javax.servlet.ServletContext;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import lombok.ToString;

/**
 * 可变常量,读取配置文件
 * @author libra
 */
@Component
@ToString
public class PropConstants implements InitializingBean{
	/** 开发环境配置 */
	@Value("${sysIsDev}")
	public boolean sysIsDev;
	
	/** 数据库配置 */
	@Value("${jdbcDriverClassName}")
	public String jdbcDriverClassName;
	@Value("${jdbcUrl}")
	public String jdbcUrl;
	@Value("${jdbcUsername}")
	public String jdbcUsername;
	@Value("${jdbcPassword}")
	public String jdbcPassword;
	
	@Autowired
	public ServletContext sc;

	/** 在MVC容器中初始化完成后, 立即执行 */
	@PostConstruct
	public void init() throws Exception {
		//D:\WorkSpace\NumWorkSpace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\hbcaMDS\
    	String realpath = sc.getRealPath("/");
    	System.out.println("DubboProviderSpringMVC部署路径:"+ realpath);
	}
	
	// 实现InitializingBean接口,properties问价加载完后调用输出
	@Override
	public void afterPropertiesSet() throws Exception {
		System.out.println( this );
	}
	
}
